export function convertListToValueEnum<T = any>(
  list?: T[],
  keyField: keyof T = 'id' as keyof T,
  valueField: keyof T = 'name' as keyof T
): Record<number, string> {
  if (!list || !Array.isArray(list)) {
    return {};
  }

  return list.reduce((acc, item) => {
    const key = Number(item[keyField]);
    // 只处理有效数字键的情况
    if (!isNaN(key)) {
      acc[key] = String(item[valueField] || '');
    }
    return acc;
  }, {} as Record<number, string>);
}
